package terra.network.packet.server;

import org.jboss.netty.buffer.ChannelBuffer;

import terra.network.packet.Packet;

public class ObjectMove extends Packet {

	public static final int ANIMATION_STAND = 0;	
	public static final int ANIMATION_ATTACK = 1;
	public static final int ANIMATION_JUMP = 2;
	public static final int ANIMATION_FALL = 3;
	public static final int ANIMATION_MOVE = 4;
	public static final byte ANIMATION_LADDER = 5;
	
	public int oId;
	public int num = Integer.MIN_VALUE;
	public float x,y,heading;
	public boolean left = true;
	public byte anim_type = ANIMATION_STAND;
	
	@Override
	public ChannelBuffer toBuffer() {
		ChannelBuffer buf = getNewBuffer();
		buf.writeByte(getId());
		buf.writeInt(oId);
		buf.writeInt(num);
		buf.writeFloat(x);
		buf.writeFloat(y);
		buf.writeFloat(heading);
		buf.writeByte(left ? 1 : 0);
		buf.writeByte(anim_type);
		return buf;
	}
	
	@Override
	public Packet fromBuffer(ChannelBuffer buf) {
		oId = buf.readInt();
		num = buf.readInt();	
		x = buf.readFloat();
		y = buf.readFloat();
		heading = buf.readFloat();
		left = buf.readByte() == 1 ? true: false;
		anim_type = buf.readByte();
		return null;
	}
	
	@Override
	public int getLength() {
		return 23;
	}
	@Override
	public boolean isDynamicLength() {
		return false;
	}
	@Override
	public byte getId() {
		return 7;
	}
	
	@Override
	public byte getPriority() {
		return PRIOR_HIGH;
	}
}
